package com.example.sj12;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;

public class IntroduceActivity1 extends AppCompatActivity {
    private ImageView iv;
    private TextView tv,tv2,tv3,tv4,tv5,tv1;
    private Button btn1,btn2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_introduce1);
        Bundle b=getIntent().getExtras();
        //获取Bundle的信息
        final String info=b.getString("name");
        final String info1=b.getString("housename");
        final String info2=b.getString("username");
        final String customer=b.getString("customer");
        final String url=b.getString("url");
        findviews();
        insert(customer);
    }

    private void insert(final String customer) {
        new Thread() {
            @Override
            public void run() {
                super.run();
                Bundle b=getIntent().getExtras();
                String info1=b.getString("housename");
                System.out.println(customer);
                System.out.println(info1);
                UserDao d = new UserDao();
                final Data get = d.yuyueinfo(customer,info1);
                Handler mHandler = new Handler(Looper.getMainLooper()) {

                    @Override
                    public void handleMessage(@NonNull Message msg) {
                        super.handleMessage(msg);
                        // 切换到主线程
                        //DataAdapter mAdapter = new DataAdapter((LinkedList<Data>) mData, mContext);//初始化适配器对象
                        //list.setAdapter(mAdapter);//设置适配器

                        tv.setText(customer);
                        tv1.setText(get.getRealname());
                        tv2.setText(get.getTel());
                        tv3.setText(get.getTimeinto());
                        tv4.setText(get.getHousename());

                    }
                };
                mHandler.sendEmptyMessage(0);
            }
        }.start();
    }
    private void findviews() {
        tv=findViewById(R.id.tv);
        tv1=findViewById(R.id.tv1);
        tv2=findViewById(R.id.tv2);
        tv3=findViewById(R.id.tv3);
        tv4=findViewById(R.id.tv4);
        tv5=findViewById(R.id.tv5);
        btn1=findViewById(R.id.btn1);
        btn2=findViewById(R.id.btn2);
    }
}
